//3.代理配置
const { createProxyMiddleware } = require("http-proxy-middleware");

const setupProxies = (app, routes) => {
  if (!routes || routes.length === 0) {
    console.log("No routes to setup proxies for");
    return;
  }
  routes.forEach((r) => {
    app.use(r.url, createProxyMiddleware(r.proxy)); //创建代理中间件，并应用到指定路由。
  });
};

exports.setupProxies = setupProxies;
